<%@page import="vo.workVO"%>
<%@page import="dto.workDTO"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src = '${pageContext.request.contextPath }/js/work.js'></script>
<link rel="stylesheet" href="${pageContext.request.contextPath }/css/work.css">
</head>
<body>
<jsp:useBean id="vo" class="vo.workVO" scope="page"/>
<jsp:setProperty property="*" name="vo"/>

<%

	int user_team;
	try{
		user_team = Integer.parseInt(request.getParameter("user_team"));
	}catch(Exception e){
		user_team = 1;
	}
	
	String m_id = (String)session.getAttribute("sessionMid");

	
	String work_view = request.getParameter("work_view");	
	if(work_view==null){
		work_view = "work_view.jsp";	
	}
	
	workVO wvo = vo;
	wvo.setM_id(m_id);
	wvo.setUser_team(user_team);
	
	workDTO wdto = new workDTO(wvo);
	ArrayList<workVO> al = wdto.list();
	
	if(wvo.getUser_team() == 1){
			// 유저
		out.print("<p><img alt='' src='../images/m_work_private.png'/> <p>");
	}
	else{
			// 팀
		out.print("<p><img alt='' src='../images/m_work_team.png'/> <p>");	
	}
%>

<div>
	<form name = 'hiddenFrm' method='post'>
	 	<input type='hidden' name="nowPage" value="<%=wvo.getNowPage()%>"/>
	 	<input type='hidden' name="w_number"/>
	 	<input type='hidden' name="user_team" value="<%=user_team%>"/>
	 	<input type='hidden' name='m_id' value="<%=wvo.getM_id()%>"/>
	</form>

	<div id="work_list">
		<div class="work_list_number">업무 번호</div>
		<div class="work_list_receiver">업무 종료일</div>
		<div class="work_list_title">제목</div>
		<div class="work_list_f_date">업무 종류</div>
		<div class="work_list_confirm">등록일</div>
	</div>

	<%
		for(int i=0; i<al.size(); i++){ 
	%>
	<div id="work_list_items">
		<div class="work_list_number"><%=al.get(i).getW_number() %></div> 
		
		<div class="work_list_receiver"><%=al.get(i).getW_end_day() %></div>
<!-- 		여기서 고뷰 -->
		<div class="work_list_title">
			<a href = '#' onclick='work_goView(<%=wdto.getNowPage()%>,<%=al.get(i).getW_number()%>,
			<%=al.get(i).getUser_team()%>)'><%=al.get(i).getW_title() %></a></div>
		
<!-- 		끝 -->
		<% if(al.get(i).getW_type() == 1){ %>
			<div class="work_list_f_date">출장</div>
		<%}else if(al.get(i).getW_type() ==2){ %>
			<div class="work_list_f_date">내근</div>
		<%}else{ %>
			<div class="work_list_f_date">회의</div>
		<%} %>
		<div class="work_list_sender"><%=al.get(i).getW_start_day() %></div>
	
	</div>
	<%} %>
	</br>
	<div id = 'list_page' align="center">
			<% if(wdto.getNowPage()==1){%>
			[처음으로]
			<%}else{%><a href='#' onclick='goPage(1,<%=user_team%>)'>[처음으로]  </a>
			<%}%>
			
		<% if(wdto.getNowBlock()==1){%>
			[이전으로]
			<%}else{%><a href="#" onclick='goPage(<%=wdto.getStartPage()-1 %>,<%=user_team%>)'> [이전으로] </a>
			<%} %>	
		<%	
		int i=0;
		for(i = wdto.getStartPage(); i<=wdto.getEndPage(); i++){%>
		<a href= "#" onclick = "goPage(<%= i %>,<%=user_team%>)"><%= i %></a>
		<%} %>
		<% if(wdto.getNowBlock()==wdto.getTotBlock()){%>
			[다음으로]
			<%}else{%><a href= '#' onclick = "goPage(<%=i %>,<%=user_team%>)">  [다음으로] </a>
			<%} %>
		
		<% if(wdto.getNowPage()==wdto.getTotPage()){%>
			[맨끝으로]
			<%}else{%><a href= "#" onclick = "goPage(<%=wdto.getTotPage() %>,<%=user_team%>)">  [맨끝으로] </a>
			<%} %>	
	</div>
	<p>
	<input type="image" src="../images/button_blue_work_write.png" value="업무 등록" onclick="input_work()" />
</div>

<div>
	<jsp:include page="<%=work_view%>"/>
</div>

</body>
</html>